Strip native= prefix from -L arg before additing it to LD_LIBRARY_PATH
authorMatt Brubeck <mbrubeck@limpet.net>
Thu, 2 Jun 2016 20:53:31 +0000 (13:53 -0700)
committerMatt Brubeck <mbrubeck@limpet.net>
Mon, 6 Jun 2016 16:25:12 +0000 (09:25 -0700)
Fixes #2765.

src/cargo/ops/cargo_rustc/compilation.rs

index 45c0e495b3aa6efcfe371ebf811c775bb8909b26..a01af9f595ab6f7796566d3a2aca85051780c8ef 100644 (file)
@@ -94,8 +94,24 @@ impl<'cfg> Compilation<'cfg> {
     pub fn process(&self, cmd: CommandType, pkg: &Package)
                    -> CargoResult<CommandPrototype> {
         let mut search_path = util::dylib_path();
+
+        // Add -L arguments, after stripping off prefixes like "native=" or "framework=".
         for dir in self.native_dirs.iter() {
-            search_path.push(dir.clone());
+            let dir = match dir.to_str() {
+                Some(s) => {
+                    let mut parts = s.splitn(2, '=');
+                    match (parts.next(), parts.next()) {
+                        (Some("native"), Some(path)) |
+                        (Some("crate"), Some(path)) |
+                        (Some("dependency"), Some(path)) |
+                        (Some("framework"), Some(path)) |
+                        (Some("all"), Some(path)) => path.into(),
+                        _ => dir.clone(),
+                    }
+                }
+                None => dir.clone(),
+            };
+            search_path.push(dir);
         }
         search_path.push(self.root_output.clone());
         search_path.push(self.deps_output.clone());
@@ -109,7 +125,7 @@ impl<'cfg> Compilation<'cfg> {
             }
         }
 
-        let metadata = pkg.manifest().metadata();
+        let metadata = pkg.manifest().metadata();
 
         cmd.env("CARGO_MANIFEST_DIR", pkg.root())
            .env("CARGO_PKG_VERSION_MAJOR", &pkg.version().major.to_string())